#include "CreditsState.h"
#include "stdafx.h"
#include <string>

#include "Game.h"
#include "../SGD Wrappers/SGD_GraphicsManager.h"
/**************************************************************/
// GetInstance
//	- store the ONLY instance in global memory
//	- return the only instance by pointer
/*static*/ CreditsState* CreditsState::GetInstance(void)
{
	static CreditsState s_Instance;

	return &s_Instance;
}


/**************************************************************/
// Enter
//	- reset the game & load resources
void CreditsState::Enter(void)
{
	// Set background color
	SGD::GraphicsManager::GetInstance()->SetClearColor({ 50, 50, 50 });	// dark gray
	offset = 0;

}

/**************************************************************/
// Exit
//	- deallocate / unload resources
/*virtual*/ void CreditsState::Exit(void)
{

}

/**************************************************************/
// Input
//	- Handles User Input
bool CreditsState::Input()
{
	SGD::InputManager* pInput = SGD::InputManager::GetInstance();

	if (Game::GetInstance()->MenuBackInput())
		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());


	return true;
}
/**************************************************************/
// Update
//	- update Objects / animations
void CreditsState::Update(float elapsedTime)
{
	if (offset >= 2800)
	{
		offset = 0.0f;
		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
	}
	offset += elapsedTime * 50;
}
/**************************************************************/
// Render
//	- Render Objects / animations
void CreditsState::Render()
{
	// Use the game's font
	BitmapFont* pFont = Game::GetInstance()->GetFont();

	// Display the game title centered at 2x scale
	pFont->Draw("MEGALANDS", 100, int(300 - offset), 2.0f, {});
	pFont->Draw("Odd Giant Studio\nS3", 150, int(400 - offset), .50f, {});

	//add the EP
	pFont->Draw("EP:", 100, int(500 - offset), .75f, {});
	pFont->Draw("John OLeske", 100, int(550 - offset), .50f, {});

	//add the AP(s)
	pFont->Draw("AP:", 100, int(650 - offset), .75f, {});
	pFont->Draw("Robert Martinez", 100, int(700 - offset), .50f, {});

	//add the Artists
	pFont->Draw("Artists:", 100, int(800 - offset), .75f, {});
	pFont->Draw("Gregory Bey\nCaris Frazier", 100, int(850 - offset), .50f, {});

	//add the developers
	pFont->Draw("Developers:", 100, int(950 - offset), .75f, {});
	pFont->Draw("William Kennedy\nJoseph Reichel\nGeorge Scott\nZachary Shields\nDavid Stout", 100, int(1000 - offset), .50f, {});

	//QA
	pFont->Draw("Quality Assurance:", 100, int(1200 - offset), .75f, {});
	pFont->Draw("Alex Brown\nWilliam Kennedy\nEthan Mills\nMichael Mozdzierz\nDeShon Thomas-Wright", 100, int(1250 - offset), .50f, {});

	//special thanks
	pFont->Draw("Special Thanks to:", 100, int(1450 - offset), .75f, {});
	pFont->Draw("Sean Hathaway\nShawn Paris", 100, int(1500 - offset), .50f, {});

	//thank you for playing
	pFont->Draw("THANK YOU FOR PLAYING!", 100, int(1800 - offset), .75f, {});
}